//登录  	
	function login(){
		$("#showReturnMSG1").attr("style","display:none");
		$("#showReturnMSG2").attr("style","display:none");
		$("#showReturnMSG3").attr("style","display:none");
		var loginType=$("input[name=loginType]:checked").val();
		var mgpwd="";
		var pwdType="";//0为密码键输入，1为键盘输入 
		//卡号登录
		if(loginType=="login_center1"){
			//判断卡号
			if(isNaN($("#kakeybon").val()) || $("#kakeybon").val()==""||$("#kakeybon").val().length!=10){
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("请输入正确的卡号");
				$("#kakeybon").focus();
				return false;
			}
			var inputCard=$("#kakeybon").val();
			inputCard=inputCard.substring(0,2);
			if("18"!=inputCard&&"48"!=inputCard){
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("该卡不是个人卡！");
				$("#kakeybon").focus();
				return false;
			}
			
			if($("#pc_pwdkeybon").val()==""||$("#pc_pwdkeybon").val().length!=6){
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("请输入正确登录密码");
				$("#pc_pwdkeybon").val("");
				$("#e_password").val("");
				$("#pc_pwdkeybon").focus();
			}else if($("#yzkeybon").val()==""){
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("请输入验证码");
				$("#yzkeybon").val("");
				$("#yzkeybon").focus();
			}else{
				if($("#e_password").val()!=""){
					mgpwd=$("#e_password").val();
					pwdType="0";
				}else{
					mgpwd=strEnc($("#pc_pwdkeybon").val());
					pwdType="1";
				}
				if(checkValiCode($('#yzkeybon').val())){
					$.ajax({   
						   type: "POST",
						   url: encodeURI("login_ajax.shtml"), 
						   data:{//发送的数据
					    		login_flag:loginType,
							   	cardno:$("#kakeybon").val(),
					    		password:mgpwd,
					    		pwdType:pwdType
					    	},
						   dataType:"json", 
						   async:false , 
						   success: function(data){
							  if(data.result=="1"&&data.loginstatus=="0"){
								  loginMain(data.cardno, data.uuid);
							  }else if(data.result=="2"){
								  	$("#showMSG1").attr("style","display:");
									$("#showMSG1_msg").html(data.resultdes);
							  }
						   },
						   error:function(){
							   alert(data.resultdes);
						   }	 
					});
				}else{
					$("#showMSG1").attr("style","display:");
					$("#showMSG1_msg").html("请输入正确的验证码");
					document.getElementById("divImg1").src="randomcode?time="+new Date().getTime();
					$("#yzkeybon").val("");
					$("#yzkeybon").focus();
				}	
			}
		}
		//手机登录
		if(loginType=="login_center2"){
			//判断手机号码
			var phone_reg = new RegExp("^13[0-9]{9}$|15[0-9]{9}$|18[0-9]{9}$");
			if(!phone_reg.test($("#sjkeybon").val())){
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("请输正确的手机号");
				$("#sjkeybon").focus();
				return false;
			}
			
			if(($("#pc_commonpwdkeybon").val()==""||$("#pc_commonpwdkeybon").val().length!=6 )&& $("#login_ms").val()=='0'){
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("请输入正确登录密码");
				$("#pc_commonpwdkeybon").val("");
				$("#e_commonpassword").val("");
				$("#pc_commonpwdkeybon").focus();
			}else if($("#dxyzkeybon").val()=="" && $("#login_ms").val()=='1'){
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("请输入短信验证码");
				$("#dxyzkeybon").val("");
				$("#dxyzkeybon").focus();
			}else if($("#sjyzkeybon").val()=="" && $("#login_ms").val()=='0'){
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("请输入验证码");
				$("#sjyzkeybon").val("");
				$("#sjyzkeybon").focus();
			}else{
				if($("#login_ms").val()=='0'){
					if($("#e_commonpassword").val()!=""){
						mgpwd=$("#e_commonpassword").val();
						pwdType="0";
					}else{
						mgpwd=strEnc($("#pc_commonpwdkeybon").val());
						pwdType="1";
					}
					if(checkValiCode($('#sjyzkeybon').val())){
						$.ajax({   
							   type: "POST",   
							   url: encodeURI("login_ajax.shtml"), 
							   data:{//发送的数据
								   login_flag:loginType,
								   	loginPass:$("#login_ms").val(),
								   	mobile:$("#sjkeybon").val(),
								   	e_mobilepassword:mgpwd,
								   	pwdType:pwdType
						    	},
							   dataType:"json", 
							   async:false , 
							   success: function(data){
								  if(data.result=="1"&&data.loginstatus=="0"){
									   loginMain(data.cardno, data.uuid);
								  }else if(data.result==2){
									    $("#showMSG1").attr("style","display:");
										$("#showMSG1_msg").html(data.resultdes);
								  }
							   },
							   error:function(){
								   alert(data.resultdes);
							   }	 
						});
					}else{
						$("#showMSG1").attr("style","display:");
						$("#showMSG1_msg").html("请输入正确的验证码");
						document.getElementById("divImg2").src="randomcode?time="+new Date().getTime();
						$("#sjyzkeybon").val("");
						$("#sjyzkeybon").focus();
					}
				}else{
					$.ajax({   
						   type: "POST",   
						   url: encodeURI("loginAjax.shtml"), 
						   data:{//发送的数据
							   login_flag:loginType,
							   	loginPass:$("#login_ms").val(),
							   	mobile:$("#sjkeybon").val(),
//							   	e_mobilepassword:encryptedString(key, encodeURIComponent($("#pc_commonkeybon").val())),
							   	mobilecode:$("#dxyzkeybon").val(),
							   	token:$("#token").val()
					    	},
						   dataType:"json", 
						   async:false , 
						   success: function(data){
							  //alert(data);
							   if(data.result=="1"&&data.loginstatus=="0"){
								   loginMain(data.cardno, data.uuid);
							  }else if(data.result==2){
								    $("#showMSG1").attr("style","display:");
									$("#showMSG1_msg").html(data.resultdes);
							  }
						   },
						   error:function(){
						   	   alert(data.resultdes);
						   }	 
					});
				}
			}
		}

	}
	
	//改变验证码
	function changeCode(){
		document.getElementById("divImg1").src="randomcode?time="+new Date().getTime() ; 
	}
	function changeCode2(){
		document.getElementById("divImg2").src="randomcode?time="+new Date().getTime() ; 
	}	
	//获取短信验证码
	function getMobileCode(){
		if($("#sjkeybon").val()==""){
			$("#showMSG1").attr("style","display:");
			$("#showMSG1_msg").html("请输入手机号");
			$("#sjkeybon").val("");
			$("#sjkeybon").focus();
		}
		$.ajax({   
			   type: "POST",   
			   url: encodeURI("getMobileCode.shtml?mobile="+$('#sjkeybon').val()), 
			   dataType:"json", 
			   async:false , 
			   success: function(data){
				  if(data.result==1){
					  $("#token").val(data.token);
				  }else if(data.result==2){
					  $("#showMSG1").attr("style","display:");
					  $("#showMSG1_msg").html(data.resultdes);
				  }  
			   },
			   error:function(){
			   	   alert("error!");
			   }	 
			});
	}
	
	//校验验证码
	function checkValiCode(code){
		var result = false;
		$.ajax({   
			   type: "POST",   
			   url: encodeURI("checkValiCode.shtml?code="+code), 
			   dataType:"text", 
			   async:false , 
			   success: function(data){
				   if(data == '1'){
					   result = true;
				   }else{			
					   result = false;
				   }
			   },
			   error:function(){
			   	   alert("error!");
			   }	 
			});
		return result;
	}
	
	//直接弹出控件
	function popupDiCard(obj){
		loginMgt();
	}
	 function loginMgt(){		
		var json = getEcardToneJson(34952);
		var miugo = document.getElementById("Miugo");	
		miugo.RegCallback (loginMgtCallBack);
		miugo.Trade(json);						
	 }
	//拍卡登录ActiveX回调函数
	function loginMgtCallBack(args){
		var json = JSON.parse(args);
		if(json.Status == 4){
			alert("未注册卡,请先注册！");
			window.location.href="http://www.miugopay.com:8007/NewCardInfoMS/reg.do?t=g";
			return;
		}
		if(json != null && json.Status == 0){
			if(json.LoginStatus==0){
	 			loginMain(json.CardNum, json.LoginUUID);
			}else{}
		}else{}
	}
	
	function changMobileType(){
		if($("#loginPass").val()=='0'){
			$("#loginPass1_div").show();
			$("#loginPass2_div").hide();
		}
		if($("#loginPass").val()=='1'){
			$("#loginPass2_div").show();
			$("#loginPass1_div").hide();
		}
	}

	//验证账户获取卡号
    function getCardNo(){
    	EV_closeAlert();
    	var json = getEcardToneJson(29749);
		var miugo = document.getElementById("Miugo");
		json.CAIC=CAIC;
		miugo.RegCallback (getCardNoCallBack);
		miugo.Trade(json);
    }
	
	//验证账户ActiveX回调函数
	function getCardNoCallBack(args){
		var json = JSON.parse(args);
		//alert(args);
		if(json.Status == 4){
			alert("未注册卡,请先注册！");
			window.location.href="reg.do";
			return;
		}

		if(json != null && json.Status == 0&&"Y"==json.CardStatusUserSet&&"Y"==json.IsAccValid&&"00"==json.CardStatus){
			$.ajax({
		    	type:"post",//请求方式
		    	url:"reg.do",//发送请求地址
		    	data:{//发送的数据
		    		m:"g",
		    		cardNo:json.CardNum
		    	},
		    	dataType:"json",  
		    	//请求成功后的回调函数有两个参数
		    	success:function(data,textStatus){
		    		if(""!=data.mobileStr || ""!=data.mailStr){
		    			document.getElementById("mobile").value=data.mobileStr;
		    			document.getElementById("mail").value=data.mailStr;
	    				document.getElementById("name").value=data.name;
		    			document.getElementById("idType").value=data.idType;
		    			document.getElementById("idNum").value=data.idNum;
		    			EV_closeAlert();
		    			if(""!=data.mobileStr){
		    				time=300;
			    			timeOut();
			    			EV_modeAlert('cpassword');
		    			}else if(""!=data.mailStr && ""==data.mobileStr){
		    				time=300;
			    			timeOut();
		    				EV_modeAlert('mpassword');
		    			}	
		    		}else{
		    			alert("没有查到手机号或邮件地址");
		    			return;
		    		}
		    	}
		    });
		}else{
			
		}
	}
	
	//清空session
	function deleteSession(){
		var check=""; 
			  $.ajax({
		    	type:"post",//请求方式
		    	url:"reg.do",//发送请求地址
		    	data:{//发送的数据
		    		m:"d",
		    		check:check
		    	}
		    });
	}
	
	//重发手机短信
	function resendPhone(){
		var phone=document.getElementById("mobile").value;
		var name=document.getElementById("name").value;
		var mail=document.getElementById("mail").value;
		$.ajax({
			type : "post",//请求方式
			url : "reg.do",//发送请求地址
			data : {//发送的数据
				m : "g",
				sphone : phone,
				sname : name,
				smail : mail
			}
		});
		document.getElementById("resendp").onclick="";
		document.getElementById("resendp1").onclick="";
		time=300;
		timeOut();
		
	}
	var timeHandler = 0;
	var time=300;
	function timeOut() {
		
		timeHandler = window.setTimeout('timeOut()', 1000);
		if (time > 0) {
			document.getElementById("resendp").value = time + "秒";
			document.getElementById("resendp1").value = time + "秒";
			time--;
		} else {
			if(time==0){
				clearTimeout(timeHandler);
				deleteSession();
				resendp.value = "再次发送短信";
				resendp1.value = "再次发送短信";
				document.getElementById("resendp").onclick=function(){resendPhone();};
				document.getElementById("resendp1").onclick=function(){resendPhone();};
				return;
			}
		}
	}
	
	//重置密码
	function ChangePassWord()
	{
		var chkCode = document.getElementById("t_chkcode").value;
		var chkCode1 = document.getElementById("t_chkcode1").value;
		var name = document.getElementById("name").value;
		var idType = document.getElementById("idType").value;
		var idNum = document.getElementById("idNum").value;
		if(IsEmpty(chkCode)&&IsEmpty(chkCode1)){
			alert("请输入验证码.");
			return;
		}else{
			$.ajax({
		    	type:"post",//请求方式
		    	url:"reg.do",//发送请求地址
		    	data:{//发送的数据
		    		m:"tp"
		    	},
		    	dataType:"json",  
		    	//请求成功后的回调函数有两个参数
		    	success:function(data,textStatus){
		    		if(""!=data.check && (data.check==chkCode||data.check==chkCode1)){
		    			//通讯
		    			var json = getEcardToneJson(28933);
		    			var miugo = document.getElementById("Miugo");
		    			//json.TransAmt = 0;
		    			//json.CAIC = CAIC;
		    			//json.UF=1;
		    			json.OprFlag="03";
		    			json.NameFlag="Y";
		    			json.Name=name;
		    			json.IdType=idType;
		    			json.IdNum=idNum;
		    			//alert(JSON.stringify(json));
		    			miugo.RegCallback(ChangePassWordCallBack);
		    			miugo.Trade(json);
		    		}else{
		    			alert("请输入正确验证码！");
		    			return;
		    		}
		    	}
		    });
		}
		
	}
	//重置密码回调函数
	function ChangePassWordCallBack(args){
		var json = JSON.parse(args);
		if(json != null && json.Status == 0){
			alert("恭喜您，密码重置成功");
			closePopup();
		}else{
			//alert("非常抱歉，修改密码失败，请重试.");
		}
	}
	
	//关闭
	function closePopup(){
		EV_closeAlert();
		time=0;
		timeHandler = window.setTimeout('timeOut()', 1000);
		if(time==0){
			clearTimeout(timeHandler);
			deleteSession();
			document.getElementById("resendp").onclick="";
			document.getElementById("t_chkcode").value="";
			document.getElementById("resendp1").onclick="";
			document.getElementById("t_chkcode1").value="";
			return;
		}
	}
	
	//进入邮箱
	function receiveMail(){
		var mail=document.getElementById("mail").value;
		var hash={ 
			'qq.com': 'http://mail.qq.com', 
			'gmail.com': 'http://mail.google.com', 
			'sina.com': 'http://mail.sina.com.cn', 
			'163.com': 'http://mail.163.com', 
			'126.com': 'http://mail.126.com', 
			'yeah.net': 'http://www.yeah.net/', 
			'sohu.com': 'http://mail.sohu.com/', 
			'tom.com': 'http://mail.tom.com/', 
			'sogou.com': 'http://mail.sogou.com/', 
			'139.com': 'http://mail.10086.cn/', 
			'hotmail.com': 'http://www.hotmail.com', 
			'live.com': 'http://login.live.com/', 
			'live.cn': 'http://login.live.cn/', 
			'live.com.cn': 'http://login.live.com.cn', 
			'189.com': 'http://webmail16.189.cn/webmail/', 
			'yahoo.com.cn': 'http://mail.cn.yahoo.com/', 
			'yahoo.cn': 'http://mail.cn.yahoo.com/', 
			'eyou.com': 'http://www.eyou.com/', 
			'21cn.com': 'http://mail.21cn.com/', 
			'188.com': 'http://www.188.com/', 
			'foxmail.coom': 'http://www.foxmail.com', 
			'miugo.net':'http://mail.miugo.net:85/'
		};
		
		var url = mail.split('@')[1]; 
		window.open(hash[url]);
	}
	
	//登录
	function loginMain(cardNo, uuid){
		 $.ajax({
		    	type:"post",//请求方式
		    	url:"login.do",//发送请求地址
		    	data:{//发送的数据
		    		m:"loginMain",
		    		cid:cardNo,
		    		lid:uuid
		    	},
		    	dataType:"json",  
		    	//请求成功后的回调函数有两个参数
		    	success:function(data,textStatus){
		    		if ('1' == data) {
		    			var rurl = parseInt($("#returnUrl").val());
		    			EV_closeAlert();
		    			if (1 != rurl) {//机票预订成功的处理
		    				var flightNo=$("#flightNo").val();
		    				var departureTime= $("#departureTime").val();
		    				var submitbuttonId= $("#submitbuttonId").val();
		    				var noLoginflightNo= $("#noLoginflightNo").val();
		    				var takeOffTime= $("#noLogintakeOffTime").val();
		    				var otherCabinflightNo=$("#otherCabinflightNo").val();
		    				var otherCabindepartureTime=$("#otherCabindepartureTime").val();
		    				var otherCabinsubmitbuttonId=$("#otherCabinsubmitbuttonId").val();
		    				var otherCabinvalidate=$("#otherCabinvalidate").val();
		    				var otherCabinLowflightNo =$("#otherCabinLowflightNo").val();
		    				var otherCabinLowdepartureTime=$("#otherCabinLowdepartureTime").val();
		    				var otherCabinLowsubmitbuttonId=$("#otherCabinLowsubmitbuttonId").val();
		    				var otherCabinLowvalidate= $("#otherCabinLowvalidate").val();
		    				var lowcabinflag=$("#lowcabinflag").val();
		    				if(flightNo!=''&&departureTime!=''&&submitbuttonId!=''){
		    					submitForm2(flightNo,departureTime,submitbuttonId);
		    				}
		    				else if(noLoginflightNo!=''&&takeOffTime!=''){
		    					bijia2(noLoginflightNo,takeOffTime);
		    				}else if(otherCabinflightNo!=''&&otherCabindepartureTime!=''&&otherCabinsubmitbuttonId!=''&&otherCabinvalidate!=''){
		    					submitOtherCabinForm2(otherCabinflightNo,otherCabindepartureTime,otherCabinsubmitbuttonId,otherCabinvalidate);
		    				}else if(lowcabinflag=='y'&&otherCabinLowflightNo!=''&&otherCabinLowdepartureTime!=''&&otherCabinLowsubmitbuttonId!=''&&otherCabinLowvalidate!=''){
		    					submitLowOtherCabinForm2(otherCabinLowflightNo,otherCabinLowdepartureTime,otherCabinLowsubmitbuttonId,otherCabinLowvalidate);
		    				}
		    				//window.location.reload(); 
		    				//window.location.href=$("#returnUrl").val();
		    			} else {//酒店预订的成果处理
		    				$("#returnUrl").val('true');
		    				$("#hotel_login_img").hide();
		    			}
		    		}
		    	}
		    });
	}

	  function login_ms(){
		  if($("#login_ms").val()=="0"){
			  $("#login_ms0").show();
			  $("#login_ms1").hide();
		  }else if($("#login_ms").val()=="1"){
			  $("#login_ms0").hide();
			  $("#login_ms1").show();
		  }
	  }
